#include <iostream>
#include <cstring>

using namespace std;

int a[100][100], s[100];
int n, res = -1000000000;

void inp()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) cin >> a[i][j];
}

void process()
{
    for (int l = 0; l < n; l++)
    {
        memset(s, 0, sizeof(s));
        for (int r = l; r < n; r++)
        {
            int sum = 0, minimum = 0;
            for (int i = 0; i < n; i++) s[i] += a[i][r];
            for (int i = 0; i < n; i++)
            {
                sum += s[i];
                if (res < sum-minimum) res = sum-minimum;
                if (minimum > sum) minimum = sum;
            }
        }
    }
}

void out()
{
    cout << res << endl;
}

int main()
{
    inp();
    process();
    out();
    return 0;
}
